VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MsComCtl.ocx"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmApprovalCanvass 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Canvass Module Approval"
   ClientHeight    =   4830
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   9675
   ControlBox      =   0   'False
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4830
   ScaleWidth      =   9675
   StartUpPosition =   2  'CenterScreen
   Begin VB.Frame Frame1 
      Height          =   4320
      Left            =   60
      TabIndex        =   3
      Top             =   30
      Width           =   9525
      Begin ITGControls.ITGTextBox txtItemNo 
         Height          =   285
         Left            =   225
         TabIndex        =   4
         Top             =   645
         Width           =   2595
         _ExtentX        =   4366
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Item"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1215
      End
      Begin ITGControls.ITGTextBox txtDesc 
         Height          =   285
         Left            =   2865
         TabIndex        =   5
         Top             =   645
         Width           =   4530
         _ExtentX        =   7885
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BackColor       =   14737632
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "ITGtext"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   4470
      End
      Begin ITGControls.ITGTextBox cTranNo 
         Height          =   285
         Left            =   225
         TabIndex        =   0
         Top             =   300
         Width           =   2580
         _ExtentX        =   4339
         _ExtentY        =   503
         SendKeysTab     =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         AllCaps         =   -1  'True
         Mandatory       =   -1  'True
         Locked          =   -1  'True
         Label           =   "Trans No."
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   1320
         TextBoxWidth    =   1200
      End
      Begin MSComctlLib.ListView lvListView 
         Height          =   2625
         Left            =   90
         TabIndex        =   6
         Top             =   1530
         Width           =   9315
         _ExtentX        =   16431
         _ExtentY        =   4630
         View            =   3
         LabelEdit       =   1
         Sorted          =   -1  'True
         MultiSelect     =   -1  'True
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         Checkboxes      =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         HotTracking     =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   7
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Supplier"
            Object.Width           =   2117
         EndProperty
         BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   1
            Text            =   "Supplier Name"
            Object.Width           =   3528
         EndProperty
         BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   2
            Text            =   "Terms"
            Object.Width           =   2117
         EndProperty
         BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   3
            Text            =   "Price"
            Object.Width           =   2117
         EndProperty
         BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   4
            Text            =   "Savings"
            Object.Width           =   2117
         EndProperty
         BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   5
            Text            =   "Others"
            Object.Width           =   2117
         EndProperty
         BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   6
            Text            =   "Rating"
            Object.Width           =   2117
         EndProperty
      End
      Begin VB.Label Label1 
         Caption         =   "Supplier List"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   165
         TabIndex        =   7
         Top             =   1245
         Width           =   1245
      End
      Begin VB.Line Line1 
         X1              =   795
         X2              =   9375
         Y1              =   1335
         Y2              =   1335
      End
   End
   Begin ITGControls.ITGCommandButton cmdCancel 
      Height          =   345
      Left            =   8430
      TabIndex        =   2
      Top             =   4410
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Cancel"
   End
   Begin ITGControls.ITGCommandButton cmdApprove 
      Height          =   345
      Left            =   7155
      TabIndex        =   1
      Top             =   4410
      Width           =   1200
      _ExtentX        =   2117
      _ExtentY        =   609
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "&Approve"
   End
End
Attribute VB_Name = "frmApprovalCanvass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'IT Group Inc. 2005.09.23

Option Explicit

'Object variables
'


Private rsHeader As New ADODB.Recordset
Private rsDetail As New ADODB.Recordset

Private sCode As String

Private mTranNo As String

Private Sub cmdApprove_Click()
Dim lCheck As Boolean
    With lvListView
        For i = 1 To .ListItems.Count
            If .ListItems(i).Checked Then
                lCheck = True
            End If
        Next i
    End With
    
    If lCheck Then
        frmToolApproval.QApprovalAction = Q_Approve
        cn.Execute ("update CANVASS_T set lApproved = 1 where cCode = '" & Trim(sCode) & "' and cTranNo ='" & Trim(cTranNo) & "'")
        UpdateLogFile "Canvass", Trim(cTranNo), "Approved"
        Unload Me
    Else
        MsgBox "Please select supplier from the list.", vbInformation + vbOKOnly, "Comunion"
    End If
End Sub

Private Sub cmdCancel_Click()
    frmToolApproval.QApprovalAction = Q_Cancel
    Unload Me
End Sub


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyEscape Then
        frmToolApproval.QApprovalAction = Q_Cancel
        Unload Me
    End If
End Sub

Private Sub Form_Load()
    mTranNo = Trim(frmToolApproval.QApprovalRef)
    
    OpenRecordset rsDetail, "*", "CANVASS_T", "WHERE cTranNo = '" & Trim(mTranNo) & "'"
    OpenRecordset rsHeader, "*", "CANVASS", "WHERE cTranNo = '" & Trim(mTranNo) & "'"
    
    SetDataField
    SetDataSource
    SetDataList
End Sub

Private Sub Form_Unload(Cancel As Integer)
    
    Set rsHeader = Nothing
    Set rsDetail = Nothing
    Set frmApprovalCanvass = Nothing
End Sub


Private Sub lvListView_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    With lvListView
        For i = 1 To .ListItems.Count
            If .ListItems(i).Checked Then
                .ListItems(i).Checked = False
            End If
        Next i
        
        .ListItems(Item.Index).Checked = True
        sCode = .ListItems(Item.Index).Text
        
    End With
End Sub

Private Sub txtItemNo_Change()
    txtDesc = ""
    txtDesc = GetValueFrTable("cDesc", "ITEM", "cItemNo = '" & Trim(txtItemNo) & "'")
End Sub


'Sets the data source of the controls
Sub SetDataSource()
    Set FrmName = Me
    BindControls rsHeader
End Sub
    
'Sets the data field for every bounded controls
Sub SetDataField()
    With rsHeader
        cTranNo.DataField = !cTranNo
        txtItemNo.DataField = !cItemNo
    End With
End Sub

Sub SetDataList()
    If rsDetail.RecordCount = 0 Then Exit Sub
    
    With lvListView
        Do Until rsDetail.EOF
            Set itmX = lvListView.ListItems.Add(, , Trim(rsDetail!cCode) & "")
            itmX.SubItems(1) = Trim(rsDetail!cName) & ""
            itmX.SubItems(2) = Trim(rsDetail!cTerm) & ""
            itmX.SubItems(3) = Format(IIf(IsNull(rsDetail!nPrice), 0, rsDetail!nPrice), "#,###.00")
            itmX.SubItems(4) = Format(IIf(IsNull(rsDetail!nSavings), 0, rsDetail!nSavings), "#,###.00")
            itmX.SubItems(5) = Trim(rsDetail!cOtherFactors) & ""
            itmX.SubItems(6) = Trim(rsDetail!cRating) & ""
            rsDetail.MoveNext
        Loop
    End With
End Sub
